home *** CD-ROM | disk | FTP | other *** search
- #ifndef H_OOF0
- #define H_OOF0
-
- // COPYRIGHT 1994 A.D. Software, All rights reserved
-
- // minimal root public layer of OOFILE database
-
- #ifndef _Windows
- #ifdef _WINDOWS
- #define _Windows
- // the difference between Borland and Visual C++, sigh!
- #endif
- #ifndef _Macintosh
- #ifdef __MWERKS__
- #define _Macintosh
- #else
- #ifdef macintosh
- #define _Macintosh
- #endif
- #endif
- #endif
- #endif
-
- #include <assert.h>
- #include <limits.h>
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- // different libs have fstream including iostream & vice-versa so need both
- #include <iostream.h>
- #include <fstream.h>
- #ifdef _Windows
- #include <strstrea.h>
- // yes this is really necessary - the long name fails under NT as the file is
- // really called strstrea.h
- #else
- #include <strstream.h>
- #endif
-
- #ifdef OOF_SmartHeap
- #include <smrtheap.hpp>
- #endif
-
- #ifndef __MWERKS__
- #ifndef OOF_GCC
- #include <io.h>
- #endif
- #ifdef macintosh
- #include <unix.h>
- #endif
- #include <fcntl.h>
- #endif
- #ifdef _Windows
- #include <windows.h>
- #endif
-
- #ifndef EXIT_SUCCESS
- #define EXIT_SUCCESS 1
- #endif
-
-
- #include "oofbool.hpp"
-
- class dbClass {
- public:
- bool hidden() const { return mHidden; };
- void hide(bool hideIt) { mHidden = hideIt; };
- virtual void describe(ostream&) {};
- protected:
- dbClass() : mHidden(false) {};
- virtual ~dbClass() {};
-
- bool mHidden;
- };
-
-
- typedef dbClass * OOF_bitPointer;
-
- class OOF_mixRefCount {
- protected:
- OOF_mixRefCount() :
- mReferences(1) {};
- unsigned int mReferences;
- };
-
-
- class OOF_DictRep : public OOF_mixRefCount {
- private:
- OOF_DictRep(unsigned int numSlots, unsigned int expandBySlots);
- OOF_DictRep(const OOF_DictRep*);
- ~OOF_DictRep();
- void operator=(const OOF_DictRep&) {assert(0);};
-
- // access protocol
- void Append(OOF_bitPointer);
- OOF_bitPointer& operator[](unsigned int index);
- OOF_bitPointer& operator[](const char *name);
- OOF_bitPointer& item(unsigned int index);
- OOF_bitPointer value(unsigned int index) const;
- void Reset();
- void ExpandToInclude(unsigned int indexToCover);
-
- // data storage
- enum {kSlotSize=sizeof(OOF_bitPointer)};
- OOF_bitPointer *mBits; // owned
- unsigned int mExpansionChunk, mNextFreeEntry, mNumSlots;
-
- friend class OOF_Dictionary;
- friend class dbView;
- friend class dbRelChain;
- };
-
-
- class OOF_Dictionary {
- // a Handle or Envelope class for OOF_DictRep
- // but independently acting as an iterator
- // contains list of dbClass
-
- // default constructor, or passing in zero items skips allocating storage
- public:
- enum {kDefExpansionChunk=10};
-
- OOF_Dictionary() ;
- OOF_Dictionary(const OOF_DictRep* rep);
- OOF_Dictionary(unsigned int numSlots);
- OOF_Dictionary(unsigned int numSlots, unsigned int expansionChunk);
- OOF_Dictionary(const OOF_Dictionary&);
- OOF_Dictionary clone() const;
- virtual ~OOF_Dictionary();
- OOF_Dictionary& operator=(const OOF_Dictionary&);
-
- // access operators
- OOF_bitPointer& operator[](unsigned int);
- OOF_bitPointer& operator[](const char*);
- OOF_bitPointer& operator[](int);
- OOF_bitPointer& item(unsigned int index);
- OOF_bitPointer value(unsigned int index) const;
- OOF_bitPointer& operator()();
- void append(OOF_bitPointer);
- void reset();
-
- // iterator protocol
- void start();
- bool more();
- void next();
- unsigned int count() const;
-
- void startVisible(bool);
- bool moreVisible(bool);
- void nextVisible(bool);
- unsigned int countVisible(bool);
-
- // other protocol
- bool allObjectsMatch(OOF_Dictionary&);
- void deleteAll();
- virtual void describe(ostream&);
- virtual void describeVisible(ostream&, bool wantVisible);
- void ownsContents(bool ownsFlag=true);
-
- protected:
- bool EntryMatchesVisibility(const dbClass*, bool) const;
-
- // data storage
- OOF_DictRep *mRep; // owned
- unsigned int mInternalIter;
- bool mOwnsContents;
- };
-
-
-
- // include inline definitions
- #include "oof0.inl"
- #endif
-